<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
</head>
<body class="gray-bg">
     <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="${path}/menu/edit" class="form-horizontal m-t" id="menuForm" method="post">
                            <input type="hidden" name='id' value='${menu.id}'/>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">父节点：</label>
                                <div class="col-sm-8">
                                    <input type="hidden" name='pid' value='${menu.pid}'/>
                                    <input type="text" disabled class="form-control" value='${parent.name}'/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单名称：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="${menu.name}" id="name" name="name" class="form-control" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单标识：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="${menu.identification}" id="identification" name="identification" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单状态：</label>
                                <div class="col-sm-8">
                                     <select class="form-control" id="status" name="status" tyle="width:100%;">
                                        <option value="1" ${menu.status eq '1'?"selected='selected'":""}>启用</option>
                                        <option value="0" ${menu.status eq '0'?"selected='selected'":""}>禁用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">按钮/菜单：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="menuButton" name="menuButton" style="width:100%;">
                                        <option value="menu" ${menu.menuButton eq 'menu'?"selected='selected'":""}>菜单</option>
                                        <option value="Button" ${menu.menuButton eq 'Button'?"selected='selected'":""}>按钮</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单图标：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="${menu.icoUrl}" id="icoUrl" name="icoUrl" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单排序：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="${menu.orderNum}" id="orderNum" name="orderNum" class="form-control" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单地址：</label>
                                <div class="col-sm-8">
                                    <input type="text" value="${menu.url}" id="url" name="url" class="form-control" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary" id="update-btn" type="button">修改菜单</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/common/hplus-js.jsp"%>
    <script src="${path}/assets/hplus/js/demo/form-validate-demo.js"></script>
    <script>
        $(document).ready(function () {
            $("#menuForm").validate();
            $("#update-btn").click(function(){
                var valid = $("#menuForm").valid();
                if(valid){
                    $("#menuForm").ajaxSubmit({
                        dataType: "json",
                        success: function (json) {
                            var code = json.code;
                            if(code == 0){
                                layer.msg('修改成功', {icon: 1});
                                setTimeout(function(){
                                    window.parent.location.reload();
                                    parent.layer.closeAll();
                                }, 1000);
                            }else{
                                layer.msg('修改发生错误' + json.msg, {icon: 5});
                            }
                        },
                        error:function(){
                            layer.msg('修改发生错误', {icon: 5});
                        }
                    });
                }else{
                	layer.msg("请填写完整信息！！！！", {
        				icon : 5
        			});
                }
            });
        });
    </script>
</body>
</html>
